//
//  PingJiaView.m
//  随便点
//
//  Created by MWJ on 15/4/8.
//  Copyright (c) 2015年 qfsoft. All rights reserved.
//

#import "PingJiaView.h"


@implementation PingJiaView{
    
    //星星评分数组
    NSMutableArray *array;
}


- (void)drawRect:(CGRect)rect {
    self.neirong.layer.borderWidth = 1;
    self.neirong.layer.masksToBounds = YES;
    
    //星星评分数组初始化
    array=[NSMutableArray array];
    
    //加载星星
    [self SetUpStar];
    
    
}
//   纯代码创建label
-(void)SetupDishesName:(NSString *)name Price:(NSString *)price Number:(NSString *)number SetY:(int)sety{
    
    //菜名
    UILabel *dishesName = [[UILabel alloc]initWithFrame:CGRectMake(20, sety, 100, 21)];
    dishesName.text = name;
    dishesName.font = [UIFont systemFontOfSize:13];
    
    //价格 和 数量
    UILabel *Price = [[UILabel alloc]initWithFrame:CGRectMake(195, sety, 100, 21)];
    Price.text = [NSString stringWithFormat:@"￥%@  *  %@",price,number];
    Price.font = [UIFont systemFontOfSize:13];
    
    //将“菜名”“价格”“数量”控件添加到view上
    [self.View1 addSubview:dishesName];
    [self.View1 addSubview:Price];
}

#pragma mark - 星星代码显示
-(void)SetUpStar{
    
    CGFloat Y=178;  //第一排星星的高度
    for (int i=0;  i < 3; i++) {
        TQStarRatingView *starRatingView = [[TQStarRatingView alloc] initWithFrame:CGRectMake(100, Y, [UIScreen mainScreen].bounds.size.width-158, 20) numberOfStar:5];
        
        starRatingView.delegate = self;
        //每增加一排星星高度＋50
        Y+=55;
        [array addObject:starRatingView];
        [self.View2 addSubview:starRatingView];
    }
    
    }

-(void)starRatingView:(TQStarRatingView *)view score:(float)score
{

    if (view== array[0]) {
        
        self.label1.text = [NSString stringWithFormat:@"%0.2f",score * 5 ];
    }
    if (view== array[1]) {
        
        self.label2.text = [NSString stringWithFormat:@"%0.2f",score * 5 ];
    }
    if (view== array[2]) {
        
        self.label3.text = [NSString stringWithFormat:@"%0.2f",score * 5 ];
    }

}
@end
